//
//  PersonalHomePageViewController.m
//  结伴
//
//  Created by mo on 16/8/8.
//  Copyright © 2016年 aleven. All rights reserved.
//

#import "PersonalHomePageViewController.h"
#import "PersonalHomePageHeader.h"
#import "PersonalHomePageTableView.h"

@interface PersonalHomePageViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tableView_main;

@end

@implementation PersonalHomePageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
  
    PersonalHomePageHeader *header = [[[NSBundle mainBundle] loadNibNamed:@"PersonalHomePageHeader" owner:nil options:nil] lastObject];
    
    self.tableView_main.tableHeaderView = header;
    
    
    
    
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 2;

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 2;
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    CGFloat height = 50;
    if (indexPath.section == 0) {
        if (indexPath.row == 0) {
            height = 110;
        }
    }
    
    
    return height;
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    id cell_main;
    
    static NSString *ID_main = @"PersonalHomePageTableView";
    PersonalHomePageTableView *cell = [tableView dequeueReusableCellWithIdentifier:ID_main];
    
    if (!cell) {
       
        cell = [[[NSBundle mainBundle] loadNibNamed:ID_main owner:nil options:nil] lastObject];
    }
    
    
    if (indexPath.section == 0) {
        
        if (indexPath.row == 1) {
            
            cell.contentLabel.text = @"结伴活动";
            cell.iconName.image = [UIImage imageNamed:@""];
            
            cell_main = cell;
        }else{
            
              UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
            
            
            UIImageView *image_main = [[UIImageView alloc] initWithFrame:CGRectMake(15, 15, 40, 40)];
            image_main.backgroundColor = [UIColor yellowColor];
            
            [cell addSubview:image_main];
            
            UILabel *lable_main = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(image_main.frame) + 10, 25, 100, 20)];
            lable_main.font = [UIFont systemFontOfSize:15.0];
        
            lable_main.text = @"个人动态 (88)";
            [cell addSubview:lable_main];
            
            
            
            CGFloat cellX = (Swidth - 150)/ 5 ;
            CGFloat cellY = 60;
            
          
            
            UIImageView *oneImageView = [[UIImageView alloc] initWithFrame:CGRectMake(65, cellY, cellX, 40)];
            oneImageView.backgroundColor = [UIColor redColor];
            [oneImageView.layer setMasksToBounds:YES];
            [oneImageView.layer setCornerRadius:4.0];
            
            [cell addSubview:oneImageView];
            UIImageView *twoImgeView = [[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(oneImageView.frame) + 10, cellY, cellX, 40)];
            twoImgeView.backgroundColor = [UIColor grayColor];
            [twoImgeView.layer setMasksToBounds:YES];
            [twoImgeView.layer setCornerRadius:4.0];
            [cell addSubview:twoImgeView];
            
            UIImageView *threeImgeView = [[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(twoImgeView.frame) + 10, cellY, cellX, 40)];
            threeImgeView.backgroundColor = [UIColor greenColor];
            [threeImgeView.layer setMasksToBounds:YES];
            [threeImgeView.layer setCornerRadius:4.0];
            [cell addSubview:threeImgeView];
            
            UIImageView *fourImageVeiw = [[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(threeImgeView.frame) + 10, cellY, cellX, 40)];
            fourImageVeiw.backgroundColor = [UIColor orangeColor];
            [fourImageVeiw.layer setMasksToBounds:YES];
            [fourImageVeiw.layer setCornerRadius:4.0];
            [cell addSubview:fourImageVeiw];
            
            UIImageView *sixImageVeiw = [[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(fourImageVeiw.frame) + 10, cellY, cellX, 40)];
            [sixImageVeiw.layer setCornerRadius:4.0];
            [sixImageVeiw.layer setMasksToBounds:YES];
            sixImageVeiw.backgroundColor = [UIColor yellowColor];

            [cell addSubview:sixImageVeiw];
            
            
            UIImageView *theArrow = [[UIImageView alloc] initWithFrame:CGRectMake(Swidth - 22, cellY + 15, 7, 15)];
            theArrow.image = [UIImage imageNamed:@"icon_in"];
            [cell addSubview:theArrow];
            
            
          //  NSString *imageName =  [self.dic[@"b"] objectForKey:@"img"];
            
//            NSArray *iamgeArray = [imageName  componentsSeparatedByString:@","];
//            
//            if (iamgeArray.count && iamgeArray.count >= 4) {
//                [oneImageView sd_setImageWithURL:[NSURL URLWithString:iamgeArray[0]]];
//                [twoImgeView sd_setImageWithURL:[NSURL URLWithString:iamgeArray[1]]];
//                [threeImgeView sd_setImageWithURL:[NSURL URLWithString:iamgeArray[2]]];
//                [fourImageVeiw sd_setImageWithURL:[NSURL URLWithString:iamgeArray[3]]];
//            }
//   
            cell_main = cell;
            
        }
        
    }else if(indexPath.section == 1) {
        
        if (indexPath.row == 0) {
            
            cell.contentLabel.text = @"相册";
            cell.iconName.image = [UIImage imageNamed:@""];
            
        }else{
            
            cell.contentLabel.text = @"喜欢";
            cell.iconName.image = [UIImage imageNamed:@""];
        }
        
        cell_main = cell;
        
    }
    
    return cell_main;
    
    
}




@end
